﻿using ReportSystem_XY.Models;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ReportSystem_XY.DAL
{
    public class UserDAL : BaseDAL<UserInfoModel>
    {
        /// <summary>
        /// 登录，返回UserId
        /// </summary>
        /// <param name="uName"></param>
        /// <param name="uPwd"></param>
        /// <returns></returns>
        public int Login(string uName, string uPwd)
        {
            string strWhere = "UserName=@UserName and UsePwd=@UserPwd and UserState=1";
            SqlParameter[] paras =
            {
                new SqlParameter("@UserName",uName),
                new SqlParameter("@UserPwd",uPwd)
            };
            UserInfoModel user = GetModel(strWhere, "UserId", paras);
            if (user != null)
            {
                return user.UserId;
            }
            else
            {
                return 0;
            }
        }
    }
}